<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="../../static/css/bootstrap.min.css" rel="stylesheet" th:href="@{/static/css/bootstrap.min.css}">
    <!-- Custom styles for this template -->
    <link href="../../static/css/dashboard.css" rel="stylesheet" th:href="@{/static/css/dashboard.css}">
</head>
<body>
<div th:replace="~{student/common::topbar}"></div>
<div class="container-fluid">
    <div class="row">
        <!--侧边栏 组件化-->
        <div th:replace="~{student/common::sidebar(active='homePage.html')}"></div>
        <main class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4" role="main">
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
                <h1 class="h3">申请换寝</h1>
                <div class="btn-toolbar mb-2 mb-md-0">
                    <div class="btn-group mr-2">
                        <button class="btn btn-sm btn-outline-secondary" id="btn-selfInfo">个人信息</button>
                        <!-- <button id="btn-free" class="btn btn-sm btn-outline-secondary">申请走读</button>-->
                        <button class="btn btn-sm btn-outline-secondary" id="btn-dormChange">申请换寝</button>
                    </div>
                    <div class="btn-group mr-2">
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-admin">管理员</button>
                        <button class="btn btn-sm btn-outline-secondary" id="btn-student">重新登陆</button>
                    </div>
                </div>
            </div>
            <form class="container-fluid col-md-5 col-md-pull-3" id="form-update-dorm" method="post"
                  th:action="@{/student/updateStuDorm}">
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="sno">学号:</label>
                    <input class="form-control" id="sno" name="sno" readonly th:value="${student.getSno()}" type="text">
                </div>
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="sname">姓名:</label>
                    <input class="form-control" id="sname" name="sname" readonly th:value="${student.getSname()}"
                           type="text">
                </div>
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="sex">性别:</label>
                    <input class="form-control" id="sex" name="sex" readonly th:value="${student.getDorm_gender()}"
                           type="text">
                </div>
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="dorm_id">宿舍:</label>
                    <select class="form-control" id="dorm_id" name="dorm_id">
                        <option th:each="dorm:${List}" th:selected="${student.getDorm_id()==dorm.getDorm_id()}"
                                th:text="${dorm.getDormPlace()+'  '+dorm.getDorm_gender()+'寝  '+dorm.getDorm_number()+'人间'}"
                                th:value="${dorm.getDorm_id()}"></option>
                    </select>
                    <p hidden id="warn-dorm-num"></p>
                </div>
                <div class="form-group form-inline">
                    <label class="form-check-inline" for="bed_id">床位</label>
                    <input class="form-control" id="bed_id" name="bed_id" required th:value="${student.getBed_id()}"
                           type="text">
                    <p hidden id="warn-bed-num"></p>
                </div>
                <div class="form-group form-inline" hidden>
                    <label class="form-check-inline" for="reason">理由</label>
                    <input class="form-control" id="reason" name="reason" placeholder="换寝室的理由!" type="text">
                </div>
                <button class="btn btn-primary " id="btn-updateDorm" type="submit">修改</button>
            </form>
        </main>
    </div>
</div>
<script src="../../static/js/jquery-3.6.0.min.js" th:src="@{/static/js/jquery-3.6.0.min.js}"
        type="text/javascript"></script>
<script src="../../static/js/bootstrap.min.js" th:src="@{/static/js/bootstrap.min.js}" type="text/javascript"></script>
<script src="../../static/js/btn.js" th:src="@{/static/js/btn.js}"></script>
<script>
    let sno = [[${session.student.getSno()}]];
    //个人信息
    /* let btnSelfInfo = $('#btn-selfInfo');
     //走读
     let btnFree = $('#btn-free');
     //换寝室
     let btnDormChange = $('#btn-dormChange');
     $.get({
         url: "/student/ajax/judgeStuDorm",
         data: {"sno": sno},
         success: function (result) {
             if (result === null) {
                 btnSelfInfo.show();
                 btnFree.hide();
                 btnDormChange.hide();
             } else {
                 if (result.sign === 0) {
                     btnSelfInfo.show();
                     btnFree.show();
                     btnDormChange.show();
                 }
                 //申请走读
                 else if (result.sign === 1) {
                     btnSelfInfo.show();
                     btnFree.show();
                     btnDormChange.hide();
                 }
                 //换寝
                 else if (result.sign === 2) {
                     btnSelfInfo.show();
                     btnFree.hide();
                     btnDormChange.show();
                 }
             }
         }
     })*/
</script>
</body>
</html>